<?php
if(empty($_POST['name'])||empty($_POST['weight'])){
	echo "缺少数据";
	return;
}

if(count($_POST['name'])==0||count($_POST['weight'])==0){
	echo "缺少数据";
	return;
}

$name=$_POST['name'];
$weight=$_POST['weight'];


header("Content-Type: application/octet-stream");     
//设置浏览器强制下载
$ua = $_SERVER["HTTP_USER_AGENT"];    
$filename = "girdbatch_".date('Y-m-d').".ini";    
$encoded_filename = urlencode($filename);    
$encoded_filename = str_replace("+", "%20", $encoded_filename);    

if (preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']) ) {      
    header('Content-Disposition:  attachment; filename="' . $encoded_filename . '"');      
} elseif (preg_match("/Firefox/", $_SERVER['HTTP_USER_AGENT'])) {      
    header('Content-Disposition: attachment; filename*="utf8' .  $filename . '"');      
} else {      
    header('Content-Disposition: attachment; filename="' .  $filename . '"');      
}  


createIni($name,$weight);

function createIni($_name,$_weight){
	for($i=0;$i<count($_name);$i++){
		$temp='/setmass ';
		$temp.=$_weight[$i];
		$temp.=' ';
		$temp.=$_name[$i];
		$temp2='/editgird ';
		$temp2.=$i+1;
		$temp2.=' ';
		$temp2.=$_name[$i];
		echo $temp2;
		echo '
';
		echo $temp;
		echo '
';
	}
}
?>